// ----------------------------------------------------------------------------
/**
 * @file    ContactList.h
 *
 * @brief   Header file for ContactList.cpp
 *
 * The contactlist class holds all of the friends of the user and displays the friends of the user.
 * This is the primary window of the application.
 *
 * @author  Siddharth Sathyam <ssathy2@gmail.com>
 * @author  Alan Ruvalcaba <aruval3@gmail.com>
 * @author  Patrick LaMontagna <plamontagna@gmail.com
 *
 * @version 1.0
 *
 * @date    November 24th, 2011
 *
 */
// ----------------------------------------------------------------------------

#ifndef CONTACTLIST_H
#define CONTACTLIST_H

#include <QMainWindow>
#include <QErrorMessage>
#include "client.h"
#include "qlistwidget.h"
#include "QVector"
#include "chatwindow.h"
#include "QCloseEvent"
#include "friendrequestswindow.h"
namespace Ui {
    class ContactList;
}

/**
 * @class   ContactList
 *
 * @brief   The ContactList helper methods
 *
 */

class ContactList : public QMainWindow
{
    Q_OBJECT

public:
    /// Explicit Constructor for ContactList
    explicit ContactList(QWidget *parent = 0);

    /// Constructor for ContactList
    ContactList(QWidget *parent, Client* client);

    /// Deconstructor for ContactList
    ~ContactList();


    void closeEvent(QCloseEvent *);

private slots:

    /**
    * @brief Slot that will determine if a user has been clicked on the ContactList
    *
    * @param item The username of the person in the ContactList
    */

    void on_listWidget_itemClicked(QListWidgetItem* item);

    /**
    * @brief Slot that will add a userName to the ContactList
    *
    * @param chatList The list of all users in the ContactList
    */

    void populateList(QStringList);


    /**
    * @brief Slot that sends the message with message attributes
    *
    * @param from The name of the from user
    * @param to The name of the to user
    * @param message The chat message
    * @param time The time the message was sent
    */

    void sendMessage(QString,QString,QString,QString);

    /**
    * @brief Slot that receives the message
    * @param fromUser the name of the user who sent message
    * @param toUser the name of the user receiving the message
    * @param message the message being sent
    * @param timeSent the time in which the message was sent
    */

    void receiveMessage(QString,QString,QString,QString);

    /**
    * @brief Slot that determines if the user clicks the exit button
    */

    void on_ExitButton_clicked();

    /**
    * @brief Slot that determines if the user clicks the settings button
    */

    void on_Settings_clicked();

    /**
    * @brief Slot that determines if the user clicks the remove buddy button
    */

    void on_RemoveBuddy_clicked();

    /**
    * @brief Slot that determines if the user clicks the add buddy button
    */
    void on_AddBuddy_clicked();

    /**
    * @brief Slot that determines if the user closes the add buddy window
    */

    void handleAddBuddyWindowClosed();

    /**
    * @brief Slot that determines if the user closes the remove buddy window
    */

    void handleRemoveBuddyWindowClosed();

    /**
    * @brief Slot that determines if the user clicks the friend request button
    */

    void on_requestsButton_clicked();

    private:
    Ui::ContactList *ui;

    /// Username variable
    QString userName;

    /// Main socket variable
    Client *mainSoc;

    /// Chat list variable
    QVector <chatWindow *> *chatList;

    /// Instance of a request window
    friendRequestsWindow *requestsWindow;

signals:

    /**
    * @brief Signal that sends the username
    *
    * @param userName The username to be sent
    */

    void passName(QString);

    /**
    * @brief Signal that sends the address of the user
    *
    * @param address The address to be passed
    */

    void passHost(QString);

    /**
    * @brief Signal sends the number of friends
    *
    * @param number The number of friends
    */
    void passNumFriends(QString);
};

#endif // CONTACTLIST_H
